/*
 * 版权所有 (c) 2022-2099 TBIT。保留所有权利。
 */

package com.tbit.main.controller;

import com.tbit.main.common.JsonResult;
import com.tbit.common.constant.MethodEnum;
import com.tbit.common.constant.ModuleEnum;
import com.tbit.main.constant.OperateLog;
import com.tbit.main.pojo.VO.AccountUserAlarmAddReqVO;
import com.tbit.main.pojo.VO.AccountUserAlarmQueryReqVO;
import com.tbit.main.pojo.VO.AccountUserAlarmRespVO;
import com.tbit.main.pojo.VO.AccountUserAlarmUpdateReqVO;
import com.tbit.main.service.AccountUserAlarmService;
import com.tbit.main.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author <a href="mailto:li.yao@tbit.com.cn">yao</a>
 * @since 2024/7/11 13:49
 * @version 4.1.0
 */
@RestController
@RequestMapping("/accountUserAlarm")
public class AccountUserAlarmController {

    @Resource
    private AccountUserAlarmService accountUserAlarmService;

    @PostMapping("/add")
    @OperateLog(module = ModuleEnum.ACCOUNT_USER_ALARM, methods = MethodEnum.ACCOUNT_USER_ALARM_ADD)
    public JsonResult<Integer> addUserAlarm(@Valid AccountUserAlarmAddReqVO reqVO) {
        accountUserAlarmService.addUserAlarm(reqVO);
        return JsonResult.succ();
    }

    @PostMapping("/delete")
    @OperateLog(module = ModuleEnum.ACCOUNT_USER_ALARM, methods = MethodEnum.ACCOUNT_USER_ALARM_DEL)
    public JsonResult<Integer> deleteUserAlarm(Long id) {
        Assert.notNull(id, "编号不能为空");
        accountUserAlarmService.deleteUserAlarm(id);
        return JsonResult.succ();
    }

    @PostMapping("/updateUserAlarmItem")
    @OperateLog(module = ModuleEnum.ACCOUNT_USER_ALARM, methods = MethodEnum.ACCOUNT_USER_ALARM_EDIT)
    public JsonResult<Integer> updateUserAlarmItem(@Valid AccountUserAlarmUpdateReqVO reqVO) {
        accountUserAlarmService.updateUserAlarmItem(reqVO);
        return JsonResult.succ();
    }

    @GetMapping("/get")
    public JsonResult<AccountUserAlarmRespVO> getUserAlarm(Long id) {
        Assert.notNull(id, "编号不能为空");
        return JsonResult.succ(accountUserAlarmService.getById(id));
    }

    @GetMapping("/list")
    public JsonResult<List<AccountUserAlarmRespVO>> getUserAlarmList(@Valid AccountUserAlarmQueryReqVO reqVO) {
        return JsonResult.succ(accountUserAlarmService.getUserAlarmList(reqVO));
    }

}
